/* eslint-disable array-callback-return */
import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Row, Col, DatePicker, Select, Input, Table, Checkbox } from 'antd';
import moment from 'moment';
import styles from '@/utils/utils.less';
import Area from '../../components/FsArea';
import DictCode from '../../components/DictCode';

const FormItem = Form.Item;
const { MonthPicker } = DatePicker;
const { Option } = Select;

class ChargeInfo extends Component {
  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'publicdata/getAreaList',
      payload: [],
    });
  }

  // 限制收费开始年月
  disabledDate = (current, id) => {
    const { form } = this.props;
    if (!id) {
      return current < moment().subtract(1, 'months');
    }
    const startDate = form.getFieldValue(id);
    if (startDate) {
      return current < moment(startDate).endOf('day');
    }
    return false;
  };

  // 选择执行地: 上方总执行地
  selectArea = value => {
    const areaId = value.key;
    const {
      dispatch,
      addinfo: {
        quoId,
        custId,
        requestAddBaseDto,
        requestInsAndAccuDto,
        insPayStyle,
        insKinds,
        isHasInjury,
        accuPayStyle,
        isSerConfig,
        pdSetFlag,
        insList,
        isHasIns,
        isHasAccu,
        isInsWageSet,
        isInsSupplyRun,
        isAccuSupplyRun,
      },
      dictCode,
      form,
    } = this.props;

    // 获取五险合不合一
    let insUnifyFlag = 1;
    dispatch({
      type: 'addinfo/fetchGetInsUnifyFlag',
      payload: { areaId },
    }).then(data => {
      insUnifyFlag = (data.data && data.data.insUnifyFlag) || 1;
      if (pdSetFlag !== '1') {
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            isInsWageSet: data.data && data.data.insUnifyFlag === 2 && isInsWageSet,
          },
        });
      }
      // 社保账户，社保组合:等选中状态
      if (insPayStyle) {
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            isSecAccu:
              (insPayStyle === '2' && areaId === '1415662' && isHasInjury && true) || false,
            requestInsAndAccuDto: {
              ...requestInsAndAccuDto,
              insAcco: undefined,
              insGrpId: undefined,
              insIde: undefined,
              injSecAccoId: undefined,
              accuAcco: undefined,
              accuGrpId: undefined,
            },
            isInsIde: false,
            insAcountList: [],
            insGroupList: [],
            insIdeList: [],
            accuAcountList: [],
            accuGroupList: [],
          },
        });
        // 获取社保账户列表
        if (custId && areaId && insKinds && !isInsSupplyRun) {
          dispatch({
            type: 'addinfo/fetchInsAcountList',
            payload: {
              custId,
              areaId,
              insKinds,
              payWay: insPayStyle,
            },
          });
        }
        if (insPayStyle === '2') {
          // 大库
          // 获取社保组合列表
          dispatch({
            type: 'addinfo/fetchInsGroupList',
            payload: {
              custId,
              areaId,
              pdId: 'PDINF_0000000001',
              insKinds,
            },
          });
          if (areaId === '1415662' && isHasInjury && !isInsSupplyRun) {
            // 石家庄维护工伤而二级户
            // 获取社保组合列表
            dispatch({
              type: 'addinfo/fetchSecAccoList',
              payload: {
                custId,
                areaId,
                payWay: insPayStyle,
                insKinds: ['5'],
              },
            }).then(secAccuIntValue => {
              form.setFieldsValue({
                'requestInsAndAccuDto.injSecAccoId': secAccuIntValue || undefined,
              });
            });
          }
        }
      }
      // 公积金账户，公积金组合灯
      if (accuPayStyle) {
        // 获取公积金账户列表
        if (!isAccuSupplyRun) {
          dispatch({
            type: 'addinfo/fetchAccuAcountList',
            payload: {
              custId,
              areaId,
              insKinds: [],
              payWay: accuPayStyle,
            },
          });
        }
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            requestInsAndAccuDto: {
              ...requestInsAndAccuDto,
              insAcco: undefined,
              insGrpId: undefined,
              insIde: undefined,
              injSecAccoId: undefined,
              accuAcco: undefined,
              accuGrpId: undefined,
            },
            isInsIde: false,
            insAcountList: [],
            insGroupList: [],
            insIdeList: [],
            accuAcountList: [],
            accuGroupList: [],
          },
        });
        if (accuPayStyle === '2') {
          // 大库
          // 获取公积金组合列表
          dispatch({
            type: 'addinfo/fetchAccuGroupList',
            payload: {
              custId,
              areaId,
              pdId: 'PDINF_0000000002',
              insKinds: ['2'],
            },
          });
        }
      }
      // 使用服务配置
      if (isSerConfig) {
        // 获取服务配置列表
        const kindList = [];
        if (pdSetFlag === '1') {
          // 产品分项打开
          requestAddBaseDto.requestPdInfo.map(item => {
            if (item.pdId === 'PDINF_0000000001' && item.cityId) {
              // 社保 五险
              if (insUnifyFlag === 1) {
                // 五险合一
                kindList.push({
                  areaId,
                  kind: 1,
                });
              } else {
                // 五险不合一
                insList.map(ins => {
                  kindList.push({
                    areaId,
                    kind: ins.itemCode,
                  });
                });
              }
            }
            if (item.pdId === 'PDINF_0000000002' && item.cityId) {
              // 公积金
              kindList.push({
                areaId,
                kind: 2,
              });
            }
          });
        } else {
          requestAddBaseDto.requestPdInfo.map(item => {
            if (item.pdId === 'PDINF_0000000001' && item.cityId) {
              // 社保 五险
              if (insUnifyFlag === 1) {
                // 五险合一
                kindList.push({
                  areaId,
                  kind: 1,
                });
              } else {
                // 五险不合一
                insList.map(ins => {
                  kindList.push({
                    areaId,
                    kind: ins.itemCode,
                  });
                });
              }
            }
            if (item.pdId === 'PDINF_0000000002' && item.cityId) {
              // 公积金
              kindList.push({
                areaId,
                kind: 2,
              });
            }
          });
        }
        // 获取服务配置列表
        dispatch({
          type: 'addinfo/fetchSerConfigList',
          payload: {
            custId,
            quoId,
            kindList,
          },
        });

        const sortNumber = (a, b) => b.ass - a.ass; // 大于到小)
        const obj = { payWayName: '', accoName: '', grpName: '' };
        let serConfigData = [];
        if (isHasAccu) {
          serConfigData = dictCode.BIZ_ACCU_TYPE.map(item => ({
            ...item,
            ass: item.itemCode,
            assName: item.itemName,
            ...obj,
          }));
        }
        if (isHasIns) {
          if (insUnifyFlag === 1) {
            // 五险合一
            serConfigData.push({
              ass: '1',
              assName: '社保',
              ...obj,
            });
          } else {
            // 五险不合一
            serConfigData = [...serConfigData, ...insList];
            serConfigData.map(item => {
              const temp = item;
              temp.ass = item.itemCode;
              temp.assName = item.itemName;
              Object.assign(item, obj);
            });
            serConfigData = serConfigData.sort(sortNumber);
          }
        }
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            serConfigData,
            requestInsAndAccuDto: {
              ...requestInsAndAccuDto,
              serSetId: undefined,
            },
          },
        });
      }
      // 委托加北京显示合同
      dispatch({
        type: 'addinfo/updateModelData',
        payload:{
          isSocialFlag: areaId && +areaId === 752252
        }
      })
      if(areaId && +areaId !== 752252){
        dispatch({
          type: 'addinfo/updateModelData',
          payload:{
            empLaborContDto: {}
          }
        })
      }
    });
    // 获取执行方
    dispatch({
      type: 'addinfo/fetchExecType',
      payload: { areaId },
    }).then(data => {
      // 更改产品分项数据
      requestAddBaseDto.requestPdInfo.map(item => {
        const temp = item;
        temp.cityId = value;
        temp.execType = (data && `${data}`) || undefined;
        temp.isSupplyRun = data === 2;
      });
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          requestAddBaseDto: {
            ...requestAddBaseDto,
            requestPdInfo: requestAddBaseDto.requestPdInfo,
            cityId: value,
            execType: (data && `${data}`) || undefined,
          },
          isSupplyRun: data === 2,
          isInsSupplyRun: data === 2 && insPayStyle === '2',
          isAccuSupplyRun: data === 2 && accuPayStyle === '2',
        },
      });
    });
  };

  // 选择执行地: 产品分项设置执行地
  selectPdSetArea = (value, index, record) => {
    const areaId = value.key;
    const {
      dispatch,
      addinfo: {
        quoId,
        custId,
        requestAddBaseDto,
        requestInsAndAccuDto,
        insPayStyle,
        insKinds,
        isHasInjury,
        accuPayStyle,
        isSerConfig,
        insList,
        isHasIns, // 有无社保
        isHasAccu, // 有无公积金
        isInsWageSet,
        isInsSupplyRun,
        isAccuSupplyRun,
      },
      dictCode,
      form,
    } = this.props;
    let {
      addinfo: { insUnifyFlag },
    } = this.props;
    // 获取五险合不合一
    dispatch({
      type: 'addinfo/fetchGetInsUnifyFlag',
      payload: { areaId, index, record },
    }).then(data => {
      if (record.pdId === 'PDINF_0000000001') {
        insUnifyFlag = (data.data && data.data.insUnifyFlag) || 1;
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            isInsWageSet: data.data && data.data.insUnifyFlag === 2 && isInsWageSet,
          },
        });
      }
      // 社保账户，社保组合:等选中状态
      if (record.pdId === 'PDINF_0000000001' && insPayStyle) {
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            isSecAccu:
              (insPayStyle === '2' && areaId === '1415662' && isHasInjury && true) || false,
            requestInsAndAccuDto: {
              ...requestInsAndAccuDto,
              insAcco: undefined,
              insGrpId: undefined,
              injSecAccoId: undefined,
            },
            isInsIde: false,
            insAcountList: [],
            insGroupList: [],
            insIdeList: [],
          },
        });
        // 获取社保账户列表
        if (custId && areaId && insKinds && !isInsSupplyRun) {
          dispatch({
            type: 'addinfo/fetchInsAcountList',
            payload: {
              custId,
              areaId,
              insKinds,
              payWay: insPayStyle,
            },
          });
        }
        if (insPayStyle === '2') {
          // 大库
          // 获取社保组合列表
          dispatch({
            type: 'addinfo/fetchInsGroupList',
            payload: {
              custId,
              areaId,
              pdId: 'PDINF_0000000001',
              insKinds,
            },
          });
          if (areaId === '1415662' && isHasInjury && !isInsSupplyRun) {
            // 石家庄维护工伤而二级户
            // 获取社保组合列表
            dispatch({
              type: 'addinfo/fetchSecAccoList',
              payload: {
                custId,
                areaId,
                payWay: insPayStyle,
                insKinds: ['5'],
              },
            }).then(secAccuIntValue => {
              form.setFieldsValue({
                'requestInsAndAccuDto.injSecAccoId': secAccuIntValue || undefined,
              });
            });
          }
        }
      }
      // 公积金账户，公积金组合灯
      if (record.pdId === 'PDINF_0000000002' && accuPayStyle) {
        // 获取公积金账户列表
        if (!isAccuSupplyRun) {
          dispatch({
            type: 'addinfo/fetchAccuAcountList',
            payload: {
              custId,
              areaId,
              insKinds: [],
              payWay: accuPayStyle,
            },
          });
        }
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            requestInsAndAccuDto: {
              ...requestInsAndAccuDto,
              accuAcco: undefined,
              accuGrpId: undefined,
            },
            accuAcountList: [],
            accuGroupList: [],
          },
        });
        if (accuPayStyle === '2') {
          // 大库
          // 获取公积金组合列表
          dispatch({
            type: 'addinfo/fetchAccuGroupList',
            payload: {
              custId,
              areaId,
              pdId: 'PDINF_0000000002',
              insKinds: ['2'],
            },
          });
        }
      }
      // 使用服务配置
      if (isSerConfig) {
        // 获取服务配置列表
        const kindList = [];
        let insAreaId = null;
        let accuAreaId = null;
        requestAddBaseDto.requestPdInfo.map(item => {
          if (item.pdId === 'PDINF_0000000001') {
            insAreaId = item.cityId && item.cityId.key;
          }
          if (item.pdId === 'PDINF_0000000002') {
            accuAreaId = item.cityId && item.cityId.key;
          }
        });
        requestAddBaseDto.requestPdInfo.map(item => {
          if (item.pdId === record.pdId && record.pdId === 'PDINF_0000000001') {
            // 社保
            if (insUnifyFlag === 1) {
              // 五险合一
              kindList.push({
                areaId,
                kind: 1,
              });
            } else {
              // 五险不
              insList.map(ins => {
                kindList.push({
                  areaId,
                  kind: ins.itemCode,
                });
              });
            }
            if (isHasAccu) {
              kindList.push({
                areaId: accuAreaId,
                kind: 2,
              });
            }
          } else if (item.pdId === record.pdId && record.pdId === 'PDINF_0000000002') {
            if (isHasIns) {
              if (insUnifyFlag === 1) {
                // 五险合一
                kindList.push({
                  areaId: insAreaId,
                  kind: 1,
                });
              } else {
                // 五险不合一
                insList.map(ins => {
                  kindList.push({
                    areaId: insAreaId,
                    kind: ins.itemCode,
                  });
                });
              }
            }
            kindList.push({
              areaId,
              kind: 2,
            });
          }
        });

        // 获取服务配置列表
        dispatch({
          type: 'addinfo/fetchSerConfigList',
          payload: {
            custId,
            quoId,
            kindList,
          },
        });

        const sortNumber = (a, b) => b.ass - a.ass; // 大于到小)
        const obj = { payWayName: '', accoName: '', grpName: '' };
        let serConfigData = dictCode.BIZ_ACCU_TYPE.map(item => ({
          ...item,
          ass: item.itemCode,
          assName: item.itemName,
          ...obj,
        }));
        if (insUnifyFlag === 1) {
          // 五险合一
          serConfigData.push({
            ass: '1',
            assName: '社保',
            ...obj,
          });
        } else {
          // 五险不合一
          serConfigData = [...serConfigData, ...insList];
          serConfigData.map(item => {
            const temp = item;
            temp.ass = item.itemCode;
            temp.assName = item.itemName;
            Object.assign(item, obj);
          });
          serConfigData = serConfigData.sort(sortNumber);
        }
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            serConfigData,
            requestInsAndAccuDto: {
              ...requestInsAndAccuDto,
              serSetId: undefined,
            },
          },
        });
      }
      // 委托加北京显示合同
      if(record.pdName === '社保代缴服务'){
        dispatch({
          type: 'addinfo/updateModelData',
          payload:{
            isSocialFlag: areaId && +areaId === 752252
          }
        })
        if(areaId && +areaId !== 752252){
          dispatch({
            type: 'addinfo/updateModelData',
            payload:{
              empLaborContDto: {}
            }
          })
        }
      }
      
    });

    // 获取执行方
    dispatch({
      type: 'addinfo/fetchExecType',
      payload: { areaId, index },
    }).then(data => {
      if (record.pdId === 'PDINF_0000000001') {
        // 更改产品险种分项数据
        requestAddBaseDto.requestPdInfo.map(item => {
          const obj = item;
          if (item.ass) {
            obj.cityId = value;
            obj.execType = `${data}`;
            obj.isSupplyRun = data === 2;
          }
        });
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            requestAddBaseDto: {
              ...requestAddBaseDto,
              requestPdInfo: requestAddBaseDto.requestPdInfo,
            },
            isInsSupplyRun: data === 2 && insPayStyle === '2',
          },
        });
      } else {
        dispatch({
          type: 'addinfo/updateModelData',
          payload: {
            isAccuSupplyRun: data === 2 && accuPayStyle === '2',
          },
        });
      }
    });
  };

  // 产品分项设置
  changePdSetFlag = e => {
    const {
      dispatch,
      addinfo: { requestAddBaseDto, isSupplyRun, insList, isAssSetFlag },
    } = this.props;
    const insKinds = [];
    insList.forEach(item => {
      insKinds.push(item.ass || item.itemCode);
    });
    dispatch({
      type: 'addinfo/updateModelData',
      payload: {
        pdSetFlag: e.target.value,
        assSetInsList: insList,
        insKinds,
      },
    });
    if (e.target.value === '1') {
      // 更改产品分项数据:业务开始日期
      requestAddBaseDto.requestPdInfo.map(item => {
        const temps = item;
        temps.startDate = requestAddBaseDto.sendBeginDate;
        temps.cityId = requestAddBaseDto.cityId;
        temps.execType = requestAddBaseDto.execType;
        temps.isSupplyRun = isSupplyRun;
      });
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          requestAddBaseDto: {
            ...requestAddBaseDto,
            requestPdInfo: requestAddBaseDto.requestPdInfo,
          },
        },
      });
    } else if (e.target.value === isAssSetFlag && isAssSetFlag === '1') {
      this.insSetFlag(isAssSetFlag);
    } else {
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          isAssSetFlag: '2',
        },
      });
    }
  };

  // 险种分项设置
  insSetFlag = isAssSetFlag => {
    const {
      dispatch,
      addinfo: { insList },
    } = this.props;
    dispatch({
      type: 'addinfo/updateIndSetData',
      payload: {
        isAssSetFlag,
        insList,
      },
    });
    const insKinds = [];
    insList.forEach(item => {
      insKinds.push(item.ass);
    });
    dispatch({
      type: 'addinfo/updateModelData',
      payload: {
        assSetInsList: insList,
        insKinds,
      },
    });
  };

  // 选择业务开始日期
  selectBeginDate = (date, dateString, record) => {
    const {
      dispatch,
      addinfo: { requestAddBaseDto },
    } = this.props;
    // 更改产品分项数据:业务开始日期
    if (!record) {
      requestAddBaseDto.requestPdInfo.map(item => {
        const temp = item;
        temp.startDate = date;
      });
    }
    if (record && record.pdId === 'PDINF_0000000001') {
      requestAddBaseDto.requestPdInfo.map(item => {
        const tempValue = item;
        if (item.ass) {
          tempValue.startDate = date;
        }
      });
    }
    dispatch({
      type: 'addinfo/updateModelData',
      payload: {
        requestAddBaseDto: {
          ...requestAddBaseDto,
          requestPdInfo: requestAddBaseDto.requestPdInfo,
        },
        sendBeginDate: dateString,
      },
    });
    // 获取劳动信息
    if (requestAddBaseDto.idCode && requestAddBaseDto.idType) {
      dispatch({
        type: 'addinfo/fetchEmpLaborCont',
        payload: {
          idType: requestAddBaseDto.idType,
          idCode: requestAddBaseDto.idCode,
          beginDate: dateString,
        },
      });
    }
  };

  // 选择执行方
  selectExecType = (value, record) => {
    const {
      dispatch,
      addinfo: { requestAddBaseDto, insPayStyle, accuPayStyle },
    } = this.props;
    if (!record) {
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          requestAddBaseDto: {
            ...requestAddBaseDto,
            execType: value,
          },
          isInsSupplyRun: insPayStyle === '2' && value === '2',
          isAccuSupplyRun: accuPayStyle === '2' && value === '2',
        },
      });
      requestAddBaseDto.requestPdInfo.map(item => {
        const temp = item;
        temp.execType = value;
      });
    }
    if (record && record.pdId === 'PDINF_0000000001') {
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          isInsSupplyRun: insPayStyle === '2' && value === '2',
        },
      });
      requestAddBaseDto.requestPdInfo.map(item => {
        const items = item;
        if (item.ass) {
          items.execType = value;
        }
      });
    }
    if (record && record.pdId === 'PDINF_0000000002') {
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          isAccuSupplyRun: accuPayStyle === '2' && value === '2',
        },
      });
    }

    dispatch({
      type: 'addinfo/updateModelData',
      payload: {
        requestAddBaseDto: {
          ...requestAddBaseDto,
          requestPdInfo: requestAddBaseDto.requestPdInfo,
        },
      },
    });
  };

  // 产品分项设置增减险种
  changeAddRedIns = (e, record) => {
    const {
      dispatch,
      addinfo: {
        quoId,
        requestAddBaseDto,
        requestInsAndAccuDto,
        insPayStyle,
        custId,
        isInsWageSet,
        isSerConfig,
        insUnifyFlag,
        isHasIns,
        isHasAccu,
      },
      form,
      dictCode,
    } = this.props;
    let isSecAccu = false;
    if (record.ass === '5') {
      isSecAccu =
        insPayStyle === '2' && record.cityId && record.cityId.key === '1415662' && e.target.checked;
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          isHasInjury: e.target.checked,
          isSecAccu,
        },
      });
    }
    if (isSecAccu) {
      // 获取工伤二级户
      dispatch({
        type: 'addinfo/fetchSecAccoList',
        payload: {
          custId,
          areaId: record.cityId && record.cityId.key,
          payWay: '2',
          insKinds: ['5'],
        },
      }).then(secAccuIntValue => {
        form.setFieldsValue({
          'requestInsAndAccuDto.injSecAccoId': secAccuIntValue || undefined,
        });
      });
    }
    let assSetInsList = [];
    requestAddBaseDto.requestPdInfo.map(item => {
      const temp = item;
      if (item.ass === record.ass) {
        temp.isSelected = e.target.checked;
      }
    });
    assSetInsList = requestAddBaseDto.requestPdInfo.filter(item => item.ass && item.isSelected);
    // 使用服务配置
    if (isSerConfig) {
      // 获取服务配置列表
      const kindList = [];
      let insAreaId = null;
      let accuAreaId = null;
      requestAddBaseDto.requestPdInfo.map(item => {
        if (item.pdId === 'PDINF_0000000001') {
          insAreaId = item.cityId && item.cityId.key;
        }
        if (item.pdId === 'PDINF_0000000002') {
          accuAreaId = item.cityId && item.cityId.key;
        }
      });
      requestAddBaseDto.requestPdInfo.map(item => {
        if (item.pdId === 'PDINF_0000000001') {
          // 社保
          assSetInsList.map(ins => {
            kindList.push({
              areaId: item.cityId.key,
              kind: ins.itemCode,
            });
          });
          if (isHasAccu) {
            kindList.push({
              areaId: accuAreaId,
              kind: 2,
            });
          }
        } else if (item.pdId === 'PDINF_0000000002') {
          if (isHasIns) {
            assSetInsList.map(ins => {
              kindList.push({
                areaId: insAreaId,
                kind: ins.itemCode,
              });
            });
          }
          kindList.push({
            areaId: accuAreaId,
            kind: 2,
          });
        }
      });

      // 获取服务配置列表
      dispatch({
        type: 'addinfo/fetchSerConfigList',
        payload: {
          custId,
          quoId,
          kindList,
        },
      });

      const sortNumber = (a, b) => b.ass - a.ass; // 大于到小)
      const obj = { payWayName: '', accoName: '', grpName: '' };
      let serConfigData = dictCode.BIZ_ACCU_TYPE.map(item => ({
        ...item,
        ass: item.itemCode,
        assName: item.itemName,
        ...obj,
      }));
      if (insUnifyFlag === 1) {
        // 五险合一
        serConfigData.push({
          ass: '1',
          assName: '社保',
          ...obj,
        });
      } else {
        // 五险不合一
        serConfigData = [...serConfigData, ...assSetInsList];
        serConfigData.map(item => {
          const tempValue = item;
          tempValue.ass = item.itemCode;
          tempValue.assName = item.itemName;
          Object.assign(item, obj);
        });
        serConfigData = serConfigData.sort(sortNumber);
      }
      dispatch({
        type: 'addinfo/updateModelData',
        payload: {
          serConfigData,
          requestInsAndAccuDto: {
            ...requestInsAndAccuDto,
            serSetId: undefined,
          },
        },
      });
    }
    const insKinds = [];
    assSetInsList.forEach(item => {
      insKinds.push(item.ass);
    });
    dispatch({
      type: 'addinfo/updateModelData',
      payload: {
        requestAddBaseDto: {
          ...requestAddBaseDto,
          requestPdInfo: requestAddBaseDto.requestPdInfo,
        },
        assSetInsList,
        insKinds,
        isInsWageSet: (assSetInsList.length && isInsWageSet) || false,
      },
    });
  };

  render() {
    const {
      form: { getFieldDecorator },
      addinfo: {
        costCenterList, // 成本中心下拉数据
        insUnifyFlag, // 五险合一
        pdSetFlag, // 产品分项设置
        isAssSetFlag, // 社保险种分项设置
        isSupplyRun, // 供应商执行
        requestAddBaseDto: { requestPdInfo },
      },
    } = this.props;
    // 页面布局
    const xl = { span: 8 };
    const lg = { span: 8 };
    const md = { span: 8 };
    const sm = 24;
    const colProps = { xl, lg, md, sm };
    // 产品分项设置column
    const columns = [
      {
        title: '产品',
        dataIndex: 'pdName',
        align: 'center',
        width: '15%',
        render: (text, record) => (
          <div>
            {record.ass ? (
              <Checkbox onChange={e => this.changeAddRedIns(e, record)} checked={record.isSelected}>
                {text}
              </Checkbox>
            ) : (
              <span>{text}</span>
            )}
          </div>
        ),
      },
      {
        title: '执行地',
        dataIndex: 'cityId',
        align: 'center',
        width: '20%',
        render: (text, record, index) => (
          <FormItem style={{ marginBottom: 0 }}>
            {getFieldDecorator(`requestAddBaseDto.requestPdInfo[${index}][cityId]`, {
              rules: [{ required: true, message: '请选择' }],
            })(
              <Area
                labelInValue
                style={{ width: '100%' }}
                onChange={value => this.selectPdSetArea(value, index, record)}
                disabled={(record.ass && true) || false}
              />
            )}
          </FormItem>
        ),
      },
      {
        title: '执行方',
        dataIndex: 'execType',
        align: 'center',
        width: '20%',
        render: (text, record, index) => (
          <FormItem style={{ marginBottom: 0 }}>
            {getFieldDecorator(`requestAddBaseDto.requestPdInfo[${index}][execType]`, {
              rules: [{ required: true, message: '请选择' }],
            })(
              <DictCode
                style={{ width: '100%' }}
                dictType="EXECUTE_POWER_TYPE"
                onChange={value => this.selectExecType(value, record)}
                disabled={(record.ass && true) || false || record.isSupplyRun}
              />
            )}
          </FormItem>
        ),
      },
      {
        title: '业务开始日期',
        dataIndex: 'sendBeginDate',
        align: 'center',
        render: (text, record, index) => (
          <div>
            <FormItem style={{ marginBottom: 0, width: '75%', float: 'left' }}>
              {getFieldDecorator(`requestAddBaseDto.requestPdInfo[${index}][startDate]`, {
                rules: [
                  {
                    required: (!record.ass && true) || (record.ass && record.isSelected),
                    message: '请选择',
                  },
                ],
              })(
                <MonthPicker
                  style={{ width: '65%' }}
                  placeholder="请选择"
                  onChange={(date, dateString) => this.selectBeginDate(date, dateString, record)}
                  format="YYYY-MM-01"
                  disabled={record.ass && !record.isSelected}
                />
              )}
            </FormItem>
            {insUnifyFlag === 2 ? (
              <div style={{ width: '25%', float: 'left' }}>
                {record.pdId === 'PDINF_0000000001' ? (
                  <a
                    style={{ lineHeight: '34px' }}
                    onClick={() => this.insSetFlag(isAssSetFlag, record)}
                  >
                    {isAssSetFlag === '1' ? '取消分项设置' : '分项设置'}
                  </a>
                ) : null}
              </div>
            ) : null}
          </div>
        ),
      },
    ];

    return (
      <div>
        <Row gutter={64}>
          <Col {...colProps}>
            <FormItem label="入职日期">
              {getFieldDecorator('requestAddBaseDto.entryDate', {
                rules: [{ required: true, message: '请选择' }],
              })(<DatePicker placeholder="请选择" style={{ width: '100%' }} />)}
            </FormItem>
          </Col>
          <Col {...colProps}>
            <FormItem label="业务开始日期">
              {getFieldDecorator('requestAddBaseDto.sendBeginDate', {
                rules: [{ required: true, message: '请选择' }],
              })(
                <MonthPicker
                  placeholder="请选择"
                  onChange={this.selectBeginDate}
                  style={{ width: '100%' }}
                  format="YYYY-MM-01"
                />
              )}
            </FormItem>
          </Col>
          {/* <Col {...colProps}>
            <FormItem label="收费开始年月">
              {getFieldDecorator('requestAddBaseDto.chrgBeginDate', {
                rules: [{ required: true, message: '请选择' }],
              })(
                <MonthPicker
                  placeholder="请选择"
                  disabledDate={this.disabledDate}
                  style={{ width: '100%' }}
                />
              )}
            </FormItem>
          </Col> */}
          <Col {...colProps}>
            <FormItem label="是否员工联系">
              {getFieldDecorator('requestAddBaseDto.addConEmpFlag', {
                rules: [{ required: true, message: '请选择' }],
              })(<DictCode dictType="YES_NO_FLAG" />)}
            </FormItem>
          </Col>
          <Col {...colProps}>
            <FormItem label="执行地">
              {getFieldDecorator('requestAddBaseDto.cityId', {
                rules: [{ required: true, message: '请输入' }],
              })(<Area onChange={this.selectArea} labelInValue />)}
            </FormItem>
          </Col>
          <Col {...colProps}>
            <FormItem label="执行方">
              {getFieldDecorator('requestAddBaseDto.execType', {
                rules: [{ required: true, message: '请选择' }],
              })(
                <DictCode
                  dictType="EXECUTE_POWER_TYPE"
                  disabled={isSupplyRun}
                  onChange={value => this.selectExecType(value)}
                />
              )}
            </FormItem>
          </Col>
          <Col {...colProps}>
            <FormItem label="所属成本中心">
              {getFieldDecorator('requestAddBaseDto.costCenter', {
                rules: [{ required: false, message: '请选择' }],
              })(
                <Select placeholder="请选择" allowClear showSearch optionFilterProp="children">
                  {costCenterList.map(options => (
                    <Option key={options.costCenterId}>{options.name}</Option>
                  ))}
                </Select>
              )}
            </FormItem>
          </Col>
          <Col {...colProps}>
            <FormItem label="办理备注">
              {getFieldDecorator('requestAddBaseDto.remark', {
                rules: [{ required: false, message: '请输入' }],
              })(<Input placeholder="请输入" maxLength={200} />)}
            </FormItem>
          </Col>

          <Col {...colProps} className={styles.pdSet}>
            <FormItem label="设置产品分项">
              {getFieldDecorator('requestAddBaseDto.pdSetFlag', {
                rules: [{ required: false, message: '请选择' }],
                initialValue: '2',
              })(<DictCode inputType="3" dictType="YES_NO_FLAG" onChange={this.changePdSetFlag} />)}
            </FormItem>
          </Col>
        </Row>
        {pdSetFlag === '1' ? (
          <div style={{ position: 'relative' }}>
            <Table
              style={{ marginTop: 16, maxWidth: 1200 }}
              className={styles.errorMsg}
              columns={columns}
              dataSource={requestPdInfo}
              rowKey={(record, index) => index}
              size="middle"
              pagination={false}
            />
            {isAssSetFlag === '1' && (
              <span className={styles.warnInfo}>
                说明：
                <br />
                如某险种不参与申报，可不勾选对应险种。
              </span>
            )}
          </div>
        ) : null}
      </div>
    );
  }
}

export default ChargeInfo;
